package src;

import javax.swing.*;
import java.awt.*;

class ThirdPage extends JFrame{

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    JScrollPane jsp;
    JPanel jp;
    JButton nextStep;
    JScrollPane js;
    JTextArea ja;
    int count = 0;
    ThirdPage(){
        this.setTitle("单纯形法计算器【作者王勾勾_QQ740597991】");
        jp = new JPanel();
        ja = new JTextArea();
        jsp = new JScrollPane(jp);
        jp.setLayout(new GridLayout(0,1));
        this.setLayout(null);

    }

    public void addSimplexTableau(SimplexTableau newSimplexTableau) {
        int widthOfMatrix = (newSimplexTableau.TABLEWIDTH-newSimplexTableau.BORDERWIDTH)*(4+newSimplexTableau.NUMBEROFCOLUMNS)+newSimplexTableau.BORDERWIDTH;
        int heightOfMatrix = (newSimplexTableau.TABLEHEIGHT-newSimplexTableau.BORDERWIDTH)*(3+newSimplexTableau.NUMBEROFLINES)+newSimplexTableau.BORDERWIDTH;
        int maxHeight = heightOfMatrix*2-newSimplexTableau.TABLEHEIGHT*2;
        if (maxHeight > 800) {
            maxHeight = 800;
        }
        jsp.setSize(widthOfMatrix+40, maxHeight+200);
        jp.add(newSimplexTableau);
        jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        this.add(jsp);
        newSimplexTableau.setPreferredSize(getSize());
        this.setSize(widthOfMatrix+60, maxHeight+260);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.setVisible(true);
    }
}